package mo.offer_special;

public class L032 {

    public boolean isAnagram(String s, String t) {
        if (s.length() != t.length()) {
            return false;
        }
        int[] sc = new int[26];
        int[] tc = new int[26];
        boolean allSame = true;
        for (int i = 0; i < s.length(); i++) {
            char c1 = s.charAt(i);
            char c2 = t.charAt(i);
            if (c1 != c2) {
                allSame = false;
            }
            sc[c1 - 'a']++;
            tc[c2 - 'a']++;
        }
        if (allSame) {
            return false;
        }
        for (int i = 0; i < 26; i++) {
            if (sc[i] != tc[i]) {
                return false;
            }
        }
        return true;
    }

}
